﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

namespace WebApplication1
{
    public class DbHelp
    {
        private static readonly string str = @"server=.;database=FXXK;uid=sa;pwd=123456";

        #region 查
        public static DataTable DataTable(string sql)
        {
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, str);
            DataTable dataTable = new DataTable();
            sqlDataAdapter.Fill(dataTable);
            return dataTable;

        }
        #endregion

        #region 修改
        public static int CMD(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(str);
            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
            sqlConnection.Open();
            var i = sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
            return i;
        }
        #endregion

    }
}